"""
终端信息DTO

@author liaochangyi
@since 2025-01-25
"""

from typing import Dict, Any


class TerminalInfoDto:
    """终端信息DTO"""
    
    def __init__(self, terminal_dict=None):
        """
        初始化终端信息
        
        Args:
            terminal_dict: 终端信息字典
        """
        self.network_license = None  # 银行卡受理终端入网编号
        self.device_type = None  # 设备类型
        self.serial_num = None  # 设备序列号
        self.encrypt_rand_num = None  # 加密随机因子
        self.secret_text = None  # 密文数据
        self.app_version = None  # 终端应用版本号
        self.mobile_country_cd = None  # 移动国家代码
        self.mobile_network_num = None  # 移动网络号码
        self.icc_id = None  # ICCID
        self.location_cd1 = None  # 位置区域码 1
        self.lbs_num1 = None  # 基站编号 1
        self.lbs_signal1 = None  # 基站信号 1
        self.location_cd2 = None  # 位置区域码 2
        self.lbs_num2 = None  # 基站编号 2
        self.lbs_signal2 = None  # 基站信号 2
        self.location_cd3 = None  # 位置区域码 3
        self.lbs_num3 = None  # 基站编号 3
        self.lbs_signal3 = None  # 基站信号 3
        self.telecom_system_id = None  # 电信系统识别码
        self.telecom_network_id = None  # 电信网络识别码
        self.telecom_lbs = None  # 电信基站
        self.telecom_lbs_signal = None  # 电信基站信号
        
        if terminal_dict:
            self.network_license = terminal_dict.get('network_license')
            self.device_type = terminal_dict.get('device_type')
            self.serial_num = terminal_dict.get('serial_num')
            self.encrypt_rand_num = terminal_dict.get('encrypt_rand_num')
            self.secret_text = terminal_dict.get('secret_text')
            self.app_version = terminal_dict.get('app_version')
            self.mobile_country_cd = terminal_dict.get('mobile_country_cd')
            self.mobile_network_num = terminal_dict.get('mobile_network_num')
            self.icc_id = terminal_dict.get('icc_id')
            self.location_cd1 = terminal_dict.get('location_cd1')
            self.lbs_num1 = terminal_dict.get('lbs_num1')
            self.lbs_signal1 = terminal_dict.get('lbs_signal1')
            self.location_cd2 = terminal_dict.get('location_cd2')
            self.lbs_num2 = terminal_dict.get('lbs_num2')
            self.lbs_signal2 = terminal_dict.get('lbs_signal2')
            self.location_cd3 = terminal_dict.get('location_cd3')
            self.lbs_num3 = terminal_dict.get('lbs_num3')
            self.lbs_signal3 = terminal_dict.get('lbs_signal3')
            self.telecom_system_id = terminal_dict.get('telecom_system_id')
            self.telecom_network_id = terminal_dict.get('telecom_network_id')
            self.telecom_lbs = terminal_dict.get('telecom_lbs')
            self.telecom_lbs_signal = terminal_dict.get('telecom_lbs_signal')
    
    def to_dict(self) -> Dict[str, Any]:
        """转换为字典格式"""
        return {
            'network_license': self.network_license,
            'device_type': self.device_type,
            'serial_num': self.serial_num,
            'encrypt_rand_num': self.encrypt_rand_num,
            'secret_text': self.secret_text,
            'app_version': self.app_version,
            'mobile_country_cd': self.mobile_country_cd,
            'mobile_network_num': self.mobile_network_num,
            'icc_id': self.icc_id,
            'location_cd1': self.location_cd1,
            'lbs_num1': self.lbs_num1,
            'lbs_signal1': self.lbs_signal1,
            'location_cd2': self.location_cd2,
            'lbs_num2': self.lbs_num2,
            'lbs_signal2': self.lbs_signal2,
            'location_cd3': self.location_cd3,
            'lbs_num3': self.lbs_num3,
            'lbs_signal3': self.lbs_signal3,
            'telecom_system_id': self.telecom_system_id,
            'telecom_network_id': self.telecom_network_id,
            'telecom_lbs': self.telecom_lbs,
            'telecom_lbs_signal': self.telecom_lbs_signal
        } 